cmake_minimum_required(VERSION  3.22)
string(ASCII 27 ESCAPE)
message("${ESCAPE}[32m cmake start ${ESCAPE}[0m")
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_CROSSCOMPILING TRUE)


set(TOOLCHAIN_PREFIX $<toolchain_prefix>)   
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc CACHE STRING "target" FORCE)
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}gcc CACHE STRING "target" FORCE)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++ CACHE STRING "target" FORCE)
set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump CACHE STRING "target" FORCE)
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy CACHE STRING "target" FORCE)
set(CMAKE_AR ${TOOLCHAIN_PREFIX}ar CACHE STRING "target" FORCE)
set(CMAKE_AS ${TOOLCHAIN_PREFIX}as CACHE STRING "target" FORCE)
set(CMAKE_LD ${TOOLCHAIN_PREFIX}ld CACHE STRING "target" FORCE)
set(CMAKE_NM ${TOOLCHAIN_PREFIX}nm CACHE STRING "target" FORCE)
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}strip CACHE STRING "target" FORCE)
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size CACHE STRING "target" FORCE)
set(CMAKE_SYSROOT $<sysroot_path>)
set(TARGET_NAME lib$<project_name>)   
file(GLOB_RECURSE SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)   
project(${TARGET_NAME} LANGUAGES C CXX) 
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS true)
add_library(${TARGET_NAME} SHARED ${SRC_FILES})
set_target_properties(${TARGET_NAME} PROPERTIES PREFIX "")
target_include_directories(
${TARGET_NAME} PUBLIC
	$<compileOption_includes>
)
target_compile_definitions(
    ${TARGET_NAME} PRIVATE
	_HARD_FLOAT_ 	
)

target_compile_options(${TARGET_NAME} PRIVATE
	$<compileOption_optimization>
	$<compileOption_debuging>
	$<compileOption_warnings>
	$<compileOption_otherCompileOptions>
)

target_link_options(
    ${TARGET_NAME} PRIVATE
	$<linkerOptions_linkerFlags>
)

target_link_directories( ${TARGET_NAME}
    PUBLIC 
	$<linkerOptions_targetLinkDirectories>
)

target_link_libraries( ${TARGET_NAME}
    PUBLIC
	$<linkerOptions_linkLib>
)


message("${ESCAPE}[32m stop cmake ${ESCAPE}[0m")